#!/usr/bin/python3
# -*- coding: UTF-8 -*-

import os
from gitlab_map import site_map
import config as c

commit_msg = 'ddd'


def git_push(filepath):
    domain_list = c.dirname_list

    for i in domain_list:
        name = i.lower()
        print(name)
        fi = site_map[name]
        fi_d = filepath
        try:
            f = fi.split('/')[1][:-4]
            cmd = "cd /d %s%s && git add -u && git commit -m '%s'" % (fi_d, f, commit_msg)
            print("push语句 >>> ", cmd)
            os.system(cmd)
            cmd = "cd /d %s%s && git checkout master && git merge hotfix/%s && git push && git checkout develop && git pull && git merge master && git push" % (fi_d, f, c.hot_fix_name)
            print("push语句 >>> ", cmd)
            os.system(cmd)
            print("-------------push done--------------")
        except Exception as e:
            print(fi + ' ***** 推送失败 *****' + str(e))


if __name__ == "__main__":
    batch_git_path = c.batch_git_path
    git_push(batch_git_path)
